﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;

using Peradigm.Framework.Domain.Security;
using Peradigm.Framework.Persistence;
using Peradigm.Framework.Persistence.Exceptions;

using Liberty.Domain.ApprovalManagement;
using Liberty.Domain.Kernel;

namespace Liberty.Persistence.ApprovalManagement
{
    public class ActivityBroker : ReferenceValueBroker<Activity>
    {
        #region Constants
        private const string SP_ALL_TYPES_OF_ACTIVITY = "[ApprovalManagement].[AllTypesOfActivity]";
        #endregion

        #region Event Handlers
        #endregion

        #region Methods
        /// <summary>
        /// Returns all active activities.
        /// </summary>
        /// <returns></returns>
        public List<Activity> AllActiveActivities()
        {
            return this.ActiveValues();
        }

        /// <summary>
        /// Returns all Activities.
        /// </summary>
        /// <returns>List of Activities</returns>
        public List<Activity> AllActivities()
        {
            return this.Values();
        }

        /// <summary>
        /// Returns an Activity corresponding to the oid.
        /// </summary>
        /// <param name="oid"></param>
        /// <returns></returns>
        public Activity ActivityWith( long oid )
        {
            return this.ValueWith( oid );
        }

        /// <summary>
        /// Returns an Activity corresponding to the description.
        /// </summary>
        /// <param name="description"></param>
        /// <returns></returns>
        public Activity ActivityWith( string description )
        {
            return this.AllActivities().Find( activity => activity.Description == description );
        }
        #endregion

        #region Properties
        #endregion

        #region Private Methods
        #endregion

        #region Private Properties
        #endregion

        #region Construction and Finalization
        public ActivityBroker( string connectionString )
            : base( connectionString, SP_ALL_TYPES_OF_ACTIVITY )
        {
        }
        #endregion

        #region Data Elements
        #endregion
    }
}
